package code.google.nfs.rpc.protocol;

/**
 * nfs-rpc
 *   Apache License
 *   
 *   http://code.google.com/p/nfs-rpc (c) 2011
 */
import com.google.protobuf.Message;

/**
 * ProtocolBuf Encoder
 * 
 * @author <a href="mailto:bluedavy@gmail.com">bluedavy</a>
 */
public class PBEncoder implements Encoder {

	public byte[] encode(Object object) throws Exception {
		if (!(object instanceof Message)) {
			throw new Exception(
					"Send object is not type of com.google.protobuf.Message,pls sure the object is generated by pb,object is: "
							+ object);
		}
		Message message = (Message) object;
		return message.toByteArray();
	}

}
